Sang Yeol Lee
February 23 2018
| 발표 시간 | 튜토리얼 내용 |
|---|---|
| 15:20 ~ 16:20 | (첫 번째 시간) 캐글 및 세팅 |
| 16:40 ~ 17:50 | (두 번째 시간) 문제 풀어보기 |
취미 : 커뮤니티 운영
캐글뽀개기 운영진 (현재, https://www.facebook.com/groups/kagglebreak)
Email : syleeie@gmail.com
summary(cars)
speed dist
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00
(https://cran.rstudio.com/bin/windows/base/)
R 프로그래밍 언어(줄여서 R)는 통계 계산과 그래픽을 위한 프로그래밍 언어이자 소프트웨어 환경이다. 뉴질랜드 오클랜드 대학의 로버트 젠틀맨(Robert Gentleman)과 로스 이하카(Ross Ihaka)에 의해 시작되어 현재는 R 코어 팀이 개발하고 있다. R은 GPL 하에 배포되는 S 프로그래밍 언어의 구현으로 GNU S라고도 한다. R은 통계 소프트웨어 개발과 자료 분석에 널리 사용되고 있으며, 패키지 개발이 용이하여 통계학자들 사이에서 통계 소프트웨어 개발에 많이 쓰이고 있다.
프로그래밍 언어 - 자유로운 데이터 분석이 가능
오픈소스 패키지의 집합 (통계, 기계학습, 금융, 생물정보학, 그래픽스)에 이르는 다양한 패키지가 무료로 제공됨.
Desktop Open Source License : https://www.rstudio.com/products/rstudio/download/
RStudio is a free and open-source integrated development environment (IDE) for R, a programming language for statistical computing and graphics. RStudio was founded by JJ Allaire,[5] creator of the programming language ColdFusion. Hadley Wickham is the Chief Scientist at RStudio
데이터 과학의 피라미드 (Monica Rogati’s fantastic Medium post “The AI Hierarchy of Needs”)
인공지능은 피라미드의 꼭대기라고 표현하는데 프레임 워 크를 접근하기 위해서 결국 데이터 수집부터 되어 있어야 함
보편적인 작업 중에는 “기본 탐색 데이터 분석”, “데이터 정리”, “시각화 만들기” 및 “연구 질문에 답변하기 위한 데이터 분석 수행"이 주로 포함됨
높은 급여와 가장 밀접하게 관련이 있는 업무는 "비즈니스 의사 결정자에게 결과 통보”, “분석으로 해결할 비즈니스 문제 식별”, “팀 프로젝트 구성 및 안내”
뉴욕시에서 택시 여행의 총 주행 거리를 예측하는 모델을 만드는 것에 도전
기본 데이터 세트는 픽업 시간, 지리적 좌표, 승객 수 및 기타 여러 변수가 포함 된 NYC 택시 및 리무진위원회에서 발급 한 데이터 세트
Google Cloud Platform의 Big Query에서 제공되는 2016 년 NYC Yellow Cab 여행 기록 데이터를 기반으로 함
데이터는 경쟁의 목적을 위해 샘플링되고 클리닝 되었음
참가자는 개별 여행 속성에 따라 테스트 세트의 각 여행 기간을 예측해야 합니다.
RMSLE(Root Mean Squared Logarithmic Error) \[ \epsilon = \sqrt{\frac{1}{n} \sum_{i=1}^n (\log(p_i + 1) - \log(a_i+1))^2 } \]
Submission File For every row in the dataset, submission files should contain two columns: id and trip_duration. The id corresponds to the column of that id in the test.csv. The file should contain a header and have the following format:
id,trip_duration
id00001,978
id00002,978
id00003,978
id00004,978
etc.
봉사자 님들은 지금 쿠폰을 나눠주세요
https://www.microsoftazurepass.com/ 들어가셔서 쿠폰 입력해보겠습니다 (쿠폰 15만 크레딧)
x <- c(88,5,12,13)
x <- c(x[1:3], 168, x[4])
x
[1] 88 5 12 168 13
length(x)
[1] 5
m <- matrix(c(1,2,3,4), nrow=2)
m
[,1] [,2]
[1,] 1 3
[2,] 2 4
m + 10:13
[,1] [,2]
[1,] 11 15
[2,] 13 17
5:8
[1] 5 6 7 8
5:1
[1] 5 4 3 2 1
#for (i in 1:length(x)){}
seq(from=12, to=30, by=3)
[1] 12 15 18 21 24 27 30
x <- rep(8,4)
x
[1] 8 8 8 8
rep(c(5,12,13),3)
[1] 5 12 13 5 12 13 5 12 13
rep(1:3,2)
[1] 1 2 3 1 2 3
x <- c(88,NA,12,168,13)
x
[1] 88 NA 12 168 13
mean(x)
[1] NA
mean(x, na.rm=T)
[1] 70.25
x <- c(88,NULL,12,168,13)
mean(x, na.rm=T)
[1] 70.25
z <- NULL
for (i in 1:10) if (i %%2 == 0) z <- c(z,i)
z
[1] 2 4 6 8 10
aburl = 'http://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.data'
abnames = c('sex','length','diameter','height','weight.w','weight.s','weight.v','weight.sh','rings')
abalone = read.table(aburl, header = F , sep = ',', col.names = abnames)
head(abalone)
sex length diameter height weight.w weight.s weight.v weight.sh rings
1 M 0.455 0.365 0.095 0.5140 0.2245 0.1010 0.150 15
2 M 0.350 0.265 0.090 0.2255 0.0995 0.0485 0.070 7
3 F 0.530 0.420 0.135 0.6770 0.2565 0.1415 0.210 9
4 M 0.440 0.365 0.125 0.5160 0.2155 0.1140 0.155 10
5 I 0.330 0.255 0.080 0.2050 0.0895 0.0395 0.055 7
6 I 0.425 0.300 0.095 0.3515 0.1410 0.0775 0.120 8
str(abalone)
'data.frame': 4177 obs. of 9 variables:
$ sex : Factor w/ 3 levels "F","I","M": 3 3 1 3 2 2 1 1 3 1 ...
$ length : num 0.455 0.35 0.53 0.44 0.33 0.425 0.53 0.545 0.475 0.55 ...
$ diameter : num 0.365 0.265 0.42 0.365 0.255 0.3 0.415 0.425 0.37 0.44 ...
$ height : num 0.095 0.09 0.135 0.125 0.08 0.095 0.15 0.125 0.125 0.15 ...
$ weight.w : num 0.514 0.226 0.677 0.516 0.205 ...
$ weight.s : num 0.2245 0.0995 0.2565 0.2155 0.0895 ...
$ weight.v : num 0.101 0.0485 0.1415 0.114 0.0395 ...
$ weight.sh: num 0.15 0.07 0.21 0.155 0.055 0.12 0.33 0.26 0.165 0.32 ...
$ rings : int 15 7 9 10 7 8 20 16 9 19 ...
dim(abalone)
[1] 4177 9
str(abalone$sex)
Factor w/ 3 levels "F","I","M": 3 3 1 3 2 2 1 1 3 1 ...
class(abalone$sex)
[1] "factor"
summary(abalone)
sex length diameter height
F:1307 Min. :0.075 Min. :0.0550 Min. :0.0000
I:1342 1st Qu.:0.450 1st Qu.:0.3500 1st Qu.:0.1150
M:1528 Median :0.545 Median :0.4250 Median :0.1400
Mean :0.524 Mean :0.4079 Mean :0.1395
3rd Qu.:0.615 3rd Qu.:0.4800 3rd Qu.:0.1650
Max. :0.815 Max. :0.6500 Max. :1.1300
weight.w weight.s weight.v weight.sh
Min. :0.0020 Min. :0.0010 Min. :0.0005 Min. :0.0015
1st Qu.:0.4415 1st Qu.:0.1860 1st Qu.:0.0935 1st Qu.:0.1300
Median :0.7995 Median :0.3360 Median :0.1710 Median :0.2340
Mean :0.8287 Mean :0.3594 Mean :0.1806 Mean :0.2388
3rd Qu.:1.1530 3rd Qu.:0.5020 3rd Qu.:0.2530 3rd Qu.:0.3290
Max. :2.8255 Max. :1.4880 Max. :0.7600 Max. :1.0050
rings
Min. : 1.000
1st Qu.: 8.000
Median : 9.000
Mean : 9.934
3rd Qu.:11.000
Max. :29.000
19세기 말-20세기 초의 유명 통계학자인 피셔(R. A. Fisher)가 연구한 데이터로서, 붓꽃(iris)의 3가지 종(setosa, versicolor, virginica)에 대해 꽃받침(sepal)과 꽃잎(petal)의 길이를 정리한 데이터
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
str(iris)
'data.frame': 150 obs. of 5 variables:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
$ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
$ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
head(iris, 3)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
apply(iris[,1:4], 2, sum)
Sepal.Length Sepal.Width Petal.Length Petal.Width
876.5 458.6 563.7 179.9
lapply(iris[,1:4], mean)
$Sepal.Length
[1] 5.843333
$Sepal.Width
[1] 3.057333
$Petal.Length
[1] 3.758
$Petal.Width
[1] 1.199333
sapply(iris[,1:4], mean)
Sepal.Length Sepal.Width Petal.Length Petal.Width
5.843333 3.057333 3.758000 1.199333
해들리 위컴
Tidy Data?
tidyverse는 공통된 디자인 철학을 공유하는 데이터 조작, 탐색 및 시각화를위한 일관된 패키지 시스템
대부분 Hadley Wickham 자신에 의해 개발되었지만, 현재 그들은 여러 공헌자들에 의해 확장되고 있습니다.
The tidyverse style guide [http://style.tidyverse.org/]
데이터 분석은 '가설 생성', '가설 확인'의 과정.
개렛 그레 몰드, 해들리 위컴에게 감사의 말을 전함.
데이터 과학의 도구로서 R은 패키지들의 집합으로 기본 함수보다 여러가지 형태로 함수가 존재함. base 함수의 이해가 끝났다면 tidyverse, caret 두 가지만 제대로 배운다면 데이터 전처리, 시각화, 모델링, 평가까지 한번에 할 수 있음